package com.dom.stor.dao.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.dom.stor.dao.entity.TTradeDate;
import com.dom.stor.dao.mapper.TTradeDateMapper;
import com.dom.stor.dao.service.ITTradeDateService;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import java.util.Date;

/**
 * <p>
 * B_系统日期表 服务实现类
 * </p>
 *
 * @author xllei
 * @since 2018-11-17
 */
@Service
public class TTradeDateServiceImpl extends ServiceImpl<TTradeDateMapper, TTradeDate> implements ITTradeDateService {
    @Override
    public Date getExchDate(int memCode) {
        Wrapper<TTradeDate> wrapper = new EntityWrapper();
        wrapper.eq("mem_code", memCode)
                .and().eq("stat", "0000")
                .orderBy("type")
                .last("limit 1");
        TTradeDate entity = this.selectOne(wrapper);
        if(ObjectUtils.isEmpty(entity)){
            return null;
        }
        return entity.getCurrDate();
    }
}
